<script type="text/javascript" language="javascript">
	(function($)
		{
			/*whatever jQuery stuff*/
			$(function()
				{
					$("#Form").validate(
						{
							ignore: "",
							rules:
							{
								media_type_id: "required",
								letters: "required",
								artist_name: "required",
								artist_name_alias: "required",
								artist_tag: "required"
							},
							showErrors: function(errorMap, errorList)
							{
								var messages='';
								for (var i = 0; i < errorList.length; i++)
								{
									messages += '- '+errorList[i].message+'\n';
								}
								if(messages) alert("<?php echo lang('requirement');?>: \n"+"¯¯¯¯¯¯¯¯¯¯ \n"+ messages);
								//this.defaultShowErrors();
							} ,
							submitHandler: function(e)
							{
								$('.ajax-loading',e).css('visibility','visible');
								if(queueSize > 0)
								{
									$('#file_upload').uploadifyUpload();
								} else
								{
									success_file = true;
								}
								var interval = setInterval(function()
									{
										if (success_file)
										{
											clearInterval(interval);
											//Send Form
											document.forms["Form"].submit();
										}
									}, 100);
							},
							onfocusout: false,
							onkeyup: false,
							onclick: false,
							messages:
							{
								media_type_id: "<?php echo lang('media_type');?>",
								letters: "<?php echo lang('letters');?>",
								artist_name: "<?php echo lang('artist_name');?>",
								artist_name_alias: "<?php echo lang('artist_name_alias');?>",
								artist_tag: "<?php echo lang('artist_tag');?>"
							}
						});

					/*Images Upload*/
					var queueSize = 0;
					var imgname= new Array();
					var success_file = false;
					$('#file_upload').uploadify(
						{
                			'uploader'  : '<?php echo base_url();?>uploadify.swf',				
                			'script'    : '<?php echo base_url();?>uploadify.php',
							'cancelImg' : '<?php echo js_asset_url("uploadify/cancel.png"); ?>',
							'folder'    : "<?php echo substr($this->temp_folder,0,-1);?>",
							'fileExt'   : '*.jpg;*.JPG;*.gif;*.GIF;*.png;*.PNG',
							'fileDesc'  : 'All Files',
							'scriptAccess' : 'always',
							'auto'      : false,
							'multi'     : true,
							'onComplete' : function(event, ID, fileObj, response, data)
							{
								imgname.push(response);
							},
							'onAllComplete' : function(event,data)
							{
								$('<input>').attr(
									{
										type: 'hidden',
										id: 'uploadify_store',
										name: 'uploadify_store',
										value: imgname
									}).appendTo('Form');
								//document.forms["Form"].submit();
								success_file=true;
							},
							'onSelectOnce' : function (event,data)
							{
								queueSize = data.fileCount;
							},
							'onCancel' : function (event,ID,fileObj,data)
							{
								queueSize = data.fileCount;
							}
						});
						
					$('.genreTag').each(function(){
						$(this).click(function(){
							if($(this).is(':checked')){
								var Delimiter = "";
								var Str = "";
								if($('#genre_tag').val() != "") Delimiter = "/";
								$('#genre_tag').val($('#genre_tag').val()+Delimiter+$(this).next().text());						
							} else {
								$('#genre_tag').val(($('#genre_tag').val().replace(new RegExp($(this).next().text()+"\/"+"|"+"\/"+$(this).next().text()+"$"+"|"+$(this).next().text(),"g"),"")));
							}
						});
					});						
					
					//ColorBox Image
					$('a[rel="gallery"]').colorbox();	
									
					//Drag && Drop
					$( ".listImages" ).sortable(
						{
							connectWith: "li",
							cursor: 'move',
							handle: 'img',
							placeholder: 'placeholder',
							forcePlaceholderSize: true,
							opacity: 0.4,
							update: function(event, ui)
							{
								//do process
								var data = $(this).sortable('serialize');
								$.ajax(
									{
										type:'post',
										url:web_path+'artist/content_management/ajax_update_image',
										data:data
									});
							}
						}).disableSelection();
						
					//DateTime Picker
					$('.datetime').datetimepicker({
						dateFormat:'dd/mm/yy',
						timeFormat:'hh:mm',
						separator:' ',
						changeMonth : true,
						changeYear : true,
						yearRange: '-100y:c+nn',
						maxDate: '-1d',
						showHour: true,		
						showMinute: true,
						showTime: true		
					});							
				});
		})(jQuery);		
</script>
<div class="wrap">
 	<div id="icon-index" class="icon32"><br /></div><h2><?php echo ucwords(str_replace('_',' ',$this->uri->segment(1)));?> &raquo; <?php echo ucwords(str_replace('_',' ',$this->uri->segment(2)));?> &raquo; <?php echo lang($this->uri->segment(3));?></h2>
</div>
<div id="wpbody-content">
    <div class="metabox-holder" id="dashboard-widgets">
		<div class="tablenav top">
			<div class="alignleft"><input type="button" value="<?php echo lang('button_back');?>" class="button-primary" onclick="javascript:history.go(-1);"/></div>
		</div>	
            <div class="inside">			
				<form id="Form" method="post" action="" name="Form">
					<table border="0" cellspacing="0" cellpadding="0" class="form-table">
						<tbody>	
						<tr>
							<th scope="row"><?php echo lang('is_publish');?></th>
							<td>
								<input type="radio" name="is_publish" value="1" <?php echo ($dataResult->is_publish == '1' ? 'checked="checked"':'');?>/> <?php echo lang('yes');?>
								<input type="radio" name="is_publish" value="0" <?php echo ($dataResult->is_publish == '0' ? 'checked="checked"':'');?>/> <?php echo lang('no');?>
							</td>
						</tr>	
						<tr>
							<th scope="row">
								<?php echo lang('artist_publish_date');?>
							</th>
							<td>
								<input type="text" name="artist_publish_date" id="artist_publish_date" class="medium-text datetime" value="<?php echo convertDatetimeToString($dataResult->artist_publish_date);?>" readonly="readonly"/>
							</td>
						</tr>											
						<tr>
							<th scope="row"><?php echo lang('media_type');?></th>
							<td>
								<select id="media_type_id" name="media_type_id" class="medium-text">
									<option value=""><?php echo lang('select_option');?></option>
									<?php foreach($dataMediaType as $value):?>
										<option value="<?php echo $value->media_type_id;?>" <?php echo ($dataResult->media_type_id == $value->media_type_id ? 'selected="selected"':'');?>><?php echo $value->media_type_name;?></option>
									<?php endforeach;?>
								</select>
							</td>
						</tr>
						<tr>
							<th scope="row"><?php echo lang('genre');?></th>
							<td>
								<?php if(!empty($dataGenre)):?> 
									<ul class="listItemsHorizontal">
										<?php foreach($dataGenre as $value):?>
										<li>
											<input type="checkbox" name="genre_id[]" value="<?php echo $value->genre_id;?>" <?php echo (in_array($value->genre_id,$dataArtistGenre) ? 'checked="checked"':'');?> class="genreTag"/> <span><?php echo $value->genre_name;?></span>
										</li>
										<?php endforeach;?>
									</ul>
								<?php endif;?>
								<input type="text" name="genre_tag" id="genre_tag" class="regular-text" value="<?php echo $dataResult->genre_tag;?>" class="genreTag"/> <?php echo lang('editable');?>
							</td>
						</tr>
						<tr>
							<th scope="row"><?php echo lang('label');?></th>
							<td>
								<select id="label_id" name="label_id" class="medium-text">
									<option value=""><?php echo lang('select_option');?></option>
									<?php foreach($dataLabel as $value):?>
										<option value="<?php echo $value->label_id;?>" <?php echo ($dataResult->label_id == $value->label_id ? 'selected="selected"':'');?>><?php echo $value->label_name;?></option>
									<?php endforeach;?>
								</select>
							</td>
						</tr>
						<tr>
							<th scope="row"><?php echo lang('is_show_recommend');?></th>
							<td>
								<input type="radio" name="is_show_recommend" value="1" <?php echo ($dataResult->is_show_recommend == '1' ? 'checked="checked"':'');?>/> <?php echo lang('yes');?>
								<input type="radio" name="is_show_recommend" value="0" <?php echo ($dataResult->is_show_recommend == '0' ? 'checked="checked"':'');?>/> <?php echo lang('no');?>
							</td>
						</tr>
						<tr>
							<th scope="row"><?php echo lang('is_show_genre');?></th>
							<td>
								<input type="radio" name="is_show_genre" value="1" <?php echo ($dataResult->is_show_genre == '1' ? 'checked="checked"':'');?>/> <?php echo lang('yes');?>
								<input type="radio" name="is_show_genre" value="0" <?php echo ($dataResult->is_show_genre == '0' ? 'checked="checked"':'');?>/> <?php echo lang('no');?>
							</td>
						</tr>
						<tr>
							<th scope="row"><?php echo lang('is_show_dream_ticket');?></th>
							<td>
								<input type="radio" name="is_show_dream_ticket" value="1" <?php echo ($dataResult->is_show_dream_ticket == '1' ? 'checked="checked"':'');?>/> <?php echo lang('yes');?>
								<input type="radio" name="is_show_dream_ticket" value="0" <?php echo ($dataResult->is_show_dream_ticket == '0' ? 'checked="checked"':'');?>/> <?php echo lang('no');?>
							</td>
						</tr>
						<tr>
							<th scope="row"><?php echo lang('is_show_archanian');?></th>
							<td>
								<input type="radio" name="is_show_archanian" value="1" <?php echo ($dataResult->is_show_archanian == '1' ? 'checked="checked"':'');?>/> <?php echo lang('yes');?>
								<input type="radio" name="is_show_archanian" value="0" <?php echo ($dataResult->is_show_archanian == '0' ? 'checked="checked"':'');?>/> <?php echo lang('no');?>
							</td>
						</tr>
						<tr>
							<th scope="row"><?php echo lang('letters');?></th>
							<td><input type="text" name="letters" id="letters" class="small-text" maxlength="1" value="<?php echo $dataResult->letters;?>"/></td>
						</tr>						
						<tr>
							<th scope="row"><?php echo lang('artist_name');?></th>
							<td><input type="text" name="artist_name" id="artist_name" class="regular-text" value="<?php echo htmlspecialchars($dataResult->artist_name, ENT_QUOTES, 'UTF-8');?>"/></td>
						</tr>
						<tr>
							<th scope="row"><?php echo lang('artist_name_alias');?></th>
							<td><input type="text" name="artist_name_alias" id="artist_name_alias" class="regular-text" value="<?php echo htmlspecialchars($dataResult->artist_name_alias, ENT_QUOTES, 'UTF-8');?>"/></td>
						</tr>						
						<tr>
							<th scope="row"><?php echo lang('artist_short_desc');?></th>
							<td>
								<textarea name="artist_short_desc" id="artist_short_desc" rows="5" class="regular-text"><?php echo $dataResult->artist_short_desc;?></textarea>
							</td>
						</tr>
						<tr>
							<th scope="row"><?php echo lang('artist_desc');?></th>
							<td><?php echo display_ckeditor('artist_desc',''.$dataResult->artist_desc.'',array('toolbar' => 'Medium','skin' => 'v2','width' => '550px','height' => '200px'),false); ?></td>
						</tr>						
						<tr>
							<th scope="row"><?php echo lang('artist_other_desc');?></th>
							<td>
								<textarea name="artist_other_desc" id="artist_other_desc" rows="5" class="regular-text"><?php echo $dataResult->artist_other_desc;?></textarea>
							</td>
						</tr>					
						<tr>
							<th scope="row"><?php echo lang('artist_tag');?></th>
							<td><input type="text" name="artist_tag" id="artist_tag" class="regular-text" value="<?php echo htmlspecialchars($dataResult->artist_tag, ENT_QUOTES, 'UTF-8');?>"/></td>
						</tr>
						<tr>
							<th scope="row"><?php echo lang('album_relate');?> <!--<a href="<?php echo base_url().'album/content_management/search_song';?>" class="tools plus search_tools"></a>--></th>
							<td>
								<ul id="album_id" class="listItems">
									<?php if(!empty($dataAlbumSong)) foreach($dataAlbumSong as $value):?>
									<li>
										<?php echo $value->album_id.' - '.$value->album_name;?>
									</li>
									<?php endforeach;?>
								</ul>
							</td>
						</tr>												
						<tr>
							<th scope="row">
								<?php echo lang('artist_image');?>
							</th>
							<td>
								<?php
								if(!empty($dataArtistImage)):?>
								<ul class="listImages">
									<?php
									foreach($dataArtistImage as $value):?>
									<li id="artist_image_id_<?php echo $value->artist_image_id;?>">
										<div>
											<a href="<?php echo image_asset_url('../uploads/artist/images/original/'.$value->artist_file_name.'.'.$value->artist_file_ext);?>" rel="gallery">
												<?php echo image_asset('../uploads/artist/images/120x120/'.$value->artist_file_name.'.'.$value->artist_file_ext,'',array('width' => 120,'height'=> 120));?>
											</a>
										</div>
										<a href="javascript:void(0);" title="<?php echo image_asset_url('../uploads/artist/images/original/'.$value->artist_file_name.'.'.$value->artist_file_ext);?>" onmouseOver="javascript:toClipboard(this)" class="tools wishlist"></a>
										<a href="<?php echo base_url();?>artist/content_management/ajax_delete_image/<?php echo $value->artist_image_id;?>" class="tools delete deleteImage"></a>									
									</li>
									<?php endforeach;?>
								</ul>
								<?php endif;?>
								<input type="file" name="file_upload" id="file_upload"/>
							</td>
						</tr>																						
						<tr>
							<th scope="row">&nbsp;</th>
							<td><p class="submit"><input type="submit" value="<?php echo lang('button_edit');?>" class="button-primary" />&nbsp;<img alt="" class="ajax-loading" src="<?php echo css_asset_url('images/wpspin_light.gif'); ?>" /></p></td>
						</tr>								
						</tbody>
					</table>
					<div class="tablenav bottom"></div>
				</form>
            </div><!-- wpbody inside -->
    </div><!-- wpcontent -->
</div><!-- wpbody-content -->